package huaan.com.mvvmdemo.http

import com.example.baselib.constants.MyConstants
import com.example.baselib.http.CustomGsonConverterFactory
import retrofit2.Retrofit


object RetrofitClient {
    var retrofit: Retrofit = Retrofit.Builder()
        .baseUrl(if (MyConstants.isTest) MyConstants.TESTURL else MyConstants.BASEURL)
        .addConverterFactory(CustomGsonConverterFactory.create())
        .build()
    var requestService: RequestService = retrofit.create(RequestService::class.java)


    fun setBaseUrl() {
        requestService = retrofit.newBuilder()
            .baseUrl(if (MyConstants.isTest) MyConstants.TESTURL else MyConstants.BASEURL)
            .addConverterFactory(CustomGsonConverterFactory.create())
            .build().create(RequestService::class.java)
    }
    fun reqApi(): RequestService {
        return requestService
    }
}